package com.dao;

import com.model.FrontUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

public interface FrontUserRepository extends JpaRepository<FrontUser, Long> {
    FrontUser getByUsername(String username);

    Boolean existsByUsername(String username);

    @Transactional
    @Modifying
    @Query(
            value = "UPDATE front_user set login_time = :data where id = :id",
            nativeQuery = true)
    int updateLoginTimeById(@Param("id") Long id, @Param("data") LocalDateTime data);
}
